<template>
  <div>
    <el-form :inline="true">
      <el-form-item>
        <el-input
          v-model="params.agency_name"
          clearable
          @keyup.enter.native="getData()"
          placeholder="公司名称"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-input
          v-model="params.register_no"
          clearable
          @keyup.enter.native="getData()"
          placeholder="营业执照"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getData()" class="btn-long" :loading="loading">查询</el-button>
      </el-form-item>
    </el-form>

    <c-table
      border
      class="table-sm"
      v-loading="loading"
      :columns="tableColumns"
      :data="tableData"
    ></c-table>
    <div class="query-pagination">
      <div></div>
      <el-pagination
        layout="total, prev, pager, next, jumper"
        :current-page.sync="params.index"
        :page-size="params.size"
        :total="totalCount"
        @current-change="getData"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      params: {
        index: 1,
        size: 15,
        'is_sync_qiyuesuo_com.eq': 1,
      },
      tableData: [],
      tableColumns: [
        { attrs: { label: '公司名称', prop: 'agency_name' } },
        { attrs: { label: '联系人', prop: 'contact' } },
        { attrs: { label: '手机号', prop: 'mobile_no' } },
        { attrs: { label: '营业执照', prop: 'register_no' } },
        { attrs: { label: '契约锁ID', prop: 'qiyuesuo_id' } },
      ],
      totalCount: 0,
      loading: false,
      order: {
        create_time: 'desc',
      },
      tableName: 'credit_agency_info',
    }
  },

  created() {
    this.getData()
  },
  methods: {
    getData(index = 1) {
      this.params.index = index
      this.loading = true
      this.$api
        .getData(this.$serviceName, this.tableName, this.params, this.order)
        .then(res => {
          const data = (res && res.data) || {}
          this.tableData = data.data || []
          this.totalCount = data.totalCount
        })
        .finally(() => {
          this.loading = false
        })
    },
  },
}
</script>
<style lang="scss" scoped></style>
